//
// Created by 11510 on 2024/6/14.
//
#include <iostream>
#include <set>
using std::cout;
using std::endl;
using std::string;
using std::ostream;
using std::set;

void test0(){
    set<int> num1;
    set<int> num2{5, 1, 2, 3, 4};
    set<int> num3(num2);
    set<int> num4(num2.begin(), num2.end());

    /**
     * set的特点：
     * 去重
     * 自动对元素升序排列
     */
    for(auto& elem: num2){
        cout << elem << " ";
    }
    cout << endl;

    for(set<int>::iterator it =  num2.begin(); it != num2.end(); it++){
        cout << *it << " ";
    }
    cout << endl;

    cout << num2.count(2) << endl;

    set<int>::iterator it2 = num2.find(99);
    if(it2 == num2.end()){
        printf("not such elem\n");
    }
    /* 不存在返回最后一个 */
    cout << *it2 << endl;
}

int main() {
    test0();
    return 0;
}
